﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Oc_MemberListItem_2 : Oc_MemberListItem
{
    public UILabel m_SbjectLabel_On;
    public UILabel m_NumLabel_On;
    public UILabel m_SbjectLabel;
    public UILabel m_NumLabel;

   

    //더미 3개 포함 5개 로컬라이제이션 키값
    //static string[] atkName = new string[5] { "combatStatTextPhyAttack", "combatStatTextMagAttack", 
    //                "combatStatTextPhyAttack", "combatStatTextPhyAttack", "combatStatTextPhyAttack" };

    //static string[] atkName = new string[5] { "근접공격", "원거리공격", 
    //                "마법공격", "파동공격", "특수공격" };
               
               // StatName.text = string.Format("{0:#,0}", TextController.GetStringWithId(atkName[stats.atkType - 1]));
    
    const int SortingNum = 13;
    //string[] tempString = new string[SortingNum]
    //{
    //    "레벨", 
    //    "강화도",
    //    "생명력",
    //    "근접 공격력",
    //    "원거리 공격력",
    //    "마법 공격력",
    //    "파동 공격력",
    //    "특수 공격력",
    //    "근접 방어도",
    //    "원거리 방어도",
    //    "마법 방어도",
    //    "파동 방어도",
    //    "특수 방어도"
    //};

    string[] tempStringKey = new string[SortingNum]
    {
        "uiCommonTextLevel", 
        "uiCommonTextEnhance",
        "combatStat20",
        "combatAtkType1",
        "combatAtkType2",
        "combatAtkType3",
        "combatAtkType4",
        "combatAtkType5",
        "combatDefType1",
        "combatDefType2",
        "combatDefType3",
        "combatDefType4",
        "combatDefType5"
    };

    public void SetListWithSortingKind(FormationSortKind sortKind)
    {
        if (m_MemberModel != null)
        {
            DBaseCharacter_New stats = m_MemberModel.m_Stat.data;
           
            m_SbjectLabel_On.text = string.Format("{0}", TextController.GetStringWithId(tempStringKey[(int)sortKind]));
            m_SbjectLabel.text = m_SbjectLabel_On.text;

            switch (sortKind)
            {
                case FormationSortKind.Level:
                    m_NumLabel_On.text = string.Format("{0:,0}", m_MemberModel.level);
                    break;
                case FormationSortKind.Inhance:
                    m_NumLabel_On.text = string.Format("{0:,0}", m_MemberModel.strengthening);
                    break;
                case FormationSortKind.HP:
                    m_NumLabel_On.text = string.Format("{0:,0}", stats.baseHP);
                    break;
                case FormationSortKind.Near_Att:
                    if (stats.atkType == 1)
                        m_NumLabel_On.text = string.Format("{0:,0}", stats.baseAtk);
                    else
                        m_NumLabel_On.text = "0";
                    break;
                case FormationSortKind.Far_Att:
                    if (stats.atkType == 2)
                        m_NumLabel_On.text = string.Format("{0:,0}", stats.baseAtk);
                    else
                        m_NumLabel_On.text = "0";
                    break;
                case FormationSortKind.Magic_Att:
                    if (stats.atkType == 3)
                        m_NumLabel_On.text = string.Format("{0:,0}", stats.baseAtk);
                    else
                        m_NumLabel_On.text = "0";
                    break;
                case FormationSortKind.Wave_Att:
                    if (stats.atkType == 4)
                        m_NumLabel_On.text = string.Format("{0:,0}", stats.baseAtk);
                    else
                        m_NumLabel_On.text = "0";
                    break;
                case FormationSortKind.Special_Att:
                    if (stats.atkType == 5)
                        m_NumLabel_On.text = string.Format("{0:,0}", stats.baseAtk);
                    else
                        m_NumLabel_On.text = "0";
                    break;
                case FormationSortKind.Near_Def:
                    m_NumLabel_On.text = string.Format("{0:,0}", stats.melee);
                    break;
                case FormationSortKind.Far_Def:
                    m_NumLabel_On.text = string.Format("{0:,0}", stats.range);
                    break;
                case FormationSortKind.Magic_Def:
                    m_NumLabel_On.text = string.Format("{0:,0}", stats.magic);
                    break;
                case FormationSortKind.Wave_Def:
                    m_NumLabel_On.text = string.Format("{0:,0}", stats.pulse);
                    break;
                case FormationSortKind.Special_Def:
                    m_NumLabel_On.text = string.Format("{0:,0}", stats.special);
                    break;
            }

            m_NumLabel.text = m_NumLabel_On.text;
        }
    }

    public override void SetList(MemberModel model)
    {
        m_MemberModel = model;

        DBaseCharacter_New stats = m_MemberModel.m_Stat.data;

        //if (m_IsSelectedLabel != null)
        //    m_IsSelectedLabel.SetActive(m_MemberModel.IsSelected);

        m_NameLabel.text = TextController.GetStringWithId(string.Format("charName{0}", m_MemberModel.name));
        m_LevelLabel.text = string.Format("Lv{0}", m_MemberModel.level);

        if (m_MemberModel.strengthening > 0)
            m_StrengtheningLabel.text = string.Format("+{0}", m_MemberModel.strengthening);
        else
            m_StrengtheningLabel.text = "";



        SetRare();
      
        PortraitControl.SetPortrait(m_OnFaceImg_Off, m_MemberModel, false);
       
        Init_On();
    }

    public void SetSelect(bool isSelect)
    {
        if (m_IsSelectedLabel != null)
            m_IsSelectedLabel.SetActive(isSelect);
    }
}
